//-----------------------------------//
//-----------------------------------//

#ifndef _MQ_MGR_H_
#define	_MQ_MGR_H_

#include <fcntl.h>           /* For O_* constants */
#include <sys/stat.h>        /* For mode constants */
#include <mqueue.h>

//-----------------------------------//
//-----------------------------------//
struct mq_mgr_t
{
    int m_inited;
    mqd_t m_mq_fd;
};

#ifdef  __cplusplus
extern "C" {
#endif

int mq_init(struct mq_mgr_t *p_mq, const char* p_mq_name, int mode, int msg_max, int msgsize_max);

int mq_send_msg(struct mq_mgr_t *p_mq, const void* p_data,int data_len,int msg_priority);

int mq_send_msg_timedout(struct mq_mgr_t *p_mq, const void* p_data,int data_len,int msg_priority,int seconds);

int mq_send_msg_timedout(struct mq_mgr_t *p_mq, const void* p_data,int data_len,int msg_priority,int milliseconds);

int mq_recv_msg(struct mq_mgr_t *p_mq, char* p_recv_buffer,int buffer_len,unsigned int* p_msg_priority);

int mq_recv_msg_timedout(struct mq_mgr_t *p_mq, char* p_recv_buffer,int buffer_len,unsigned int* p_msg_priority,int seconds);

int mq_uninit(struct mq_mgr_t *p_mq);

#ifdef  __cplusplus
}
#endif

#endif
